<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Request;
use app\index\model\user;
class Index extends Controller
{
    public function index()
    {
    	if (input('?get.code')) {
    		$this->redirect("zhu/main");
    	}
        return $this->fetch('index');
    }
         public function login(){
		if(request()->isPost()){
			$admin=new user();
			$data=input('post.');
			// var_dump($data);die;
			$num=$admin->login($data);
			if($num==3){
				$this->success('信息正确，正在为您跳转','zhu/main');
			}else{
				$this->error('用户名或密码错误');
			}
		}
	}
	// public function login(){
	// 	$user=Db::name('user')->find();
	// 	if ($user) {
	// 		$this->success('信息正确，正在为您跳转','zhu/main');
	// 	}else{
 //            $this->error('用户名或密码错误');
	// 	}
	// }
	function qqlogin(){
		$appid = '101353491';
      $appkey = 'df4e46ba7da52f787c6e3336d30526e4';
     $redirect_uri = 'http://www.iwebshop.com/index.php';
    $state = rand(1000, 9999);
    $url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id='.$appid.'&redirect_uri='.$redirect_uri.'&state='.$state;


$this->redirect($url);
	}

 }
